package com.itbaizhan.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author spf
 * @date 2024/3/3
 * @time 20:48
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseResult<T> {

    private int code;

    private String message;

    private T data;

    public static <T> BaseResult<T> ok(){
        return new BaseResult(CodeEnum.SUCCESS.getCode(), CodeEnum.SUCCESS.getMessage(), null);
    }

    public static <T> BaseResult<T> ok(T data){
        return new BaseResult(CodeEnum.SUCCESS.getCode(), CodeEnum.SUCCESS.getMessage(), data);
    }

    public static <T> BaseResult<T> error(){
        return new BaseResult(CodeEnum.ERROR.getCode(), CodeEnum.ERROR.getMessage(), null);
    }

}
